#include "lan2calgridword.h"
#include "lan2Calssp.h"

#include <QGraphicsDropShadowEffect>
#include <QPainter>
LAN2STA
Lan2CalSsp::Lan2CalSsp(int width, int height, QWidget *parent) : QFrame(parent)
{
    this->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint );
//    this->setAttribute(Qt::WA_StyledBackground,true);
    this->setAttribute(Qt::WA_TranslucentBackground,true);
    this->setWindowOpacity(0.9);
//    QPalette pa=this->palette();
//    pa.setColor(QPalette::Background,QColor("#c9c9c9"));
//    this->setPalette(pa);
    this->setStyleSheet("QWidget{background:#ffffff}");
    this->setFixedSize(width,height);

    QGraphicsDropShadowEffect* shadow=new QGraphicsDropShadowEffect(this);
    shadow->setOffset(0,0);
    shadow->setColor(Qt::black);
    shadow->setBlurRadius(5);
    this->setGraphicsEffect(shadow);


    mgrid=new QGridLayout(this);
//    mgrid->setContentsMargins(24,24,24,24);
    this->setLayout(mgrid);
//    vbox->addLayout(mgrid);
    QList<Lan2CalGridWord*> list_Gridwords;
    list_Gridwords.clear();
    qDeleteAll(list_Gridwords);
    for(int i=0;i<60;i++)
    {
        list_Gridwords.append(new Lan2CalGridWord(QString("%1").arg(i,2,10,QLatin1Char('0')),20,this));
        connect(list_Gridwords.at(i),SIGNAL(sign_click(QString)),this,SLOT(slot_click(QString)));
    }




    int i=0;
    for(int r=0;r<6;r++){
        for(int c=0;c<10;c++){
            if(i<60){
                mgrid->addWidget(list_Gridwords.at(i),r,c);

            }
            i++;

        }
    }
}

void Lan2CalSsp::slot_click(const QString & s)
{
    this->setHidden(true);
    emit sign_sendword(s);
}

void Lan2CalSsp::paintEvent(QPaintEvent *event)
{
#if 1
    QPainter painter(this);
    painter.fillRect(this->rect().adjusted(5,5,-5,-5),QColor("#ffffff"));
#endif
}

LAN2END
